//
//  YHYNewTaskViewController.m
//  Home
//
//  Created by 杨泓晔 on 16/4/15.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYNewTaskViewController.h"
//#import "WSCustomPickerView.h"
#import "WSRequirementView.h"
#import "WSShopInfoNextView.h"
#import "YHYDesignerPTableViewCell.h"
@interface YHYNewTaskViewController ()<UITableViewDataSource,UITableViewDelegate,WSRequirementViewDelegate,WSShopInfoNextViewDelegate>
@property (nonatomic,retain)UITableView *myTableView;
@property (nonatomic,retain)NSArray *array;
@property (nonatomic,retain)NSString *mystr;

@end

@implementation YHYNewTaskViewController
- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationController.navigationBarHidden = NO;
    self.title = @"个人信息";
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = LV;
    
//    左侧的图标
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(Back:)];
    
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

    [self creatView];
}

- (void)creatView{
    self.array = [NSArray arrayWithObjects:@"任务类型", @"任务地址", @"任务面积", @"设计要求", @"风格要求", @"设计经验", @"费用范围",@"参考图片",@"详细描述", nil];
    
    
    self.myTableView = [UITableView new];
    
    [self.view addSubview:self.myTableView];
    self.myTableView.rowHeight = 50 * AUTO_HEIGHT;
   // self.myTableView.sectionFooterHeight = 10;
    [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(self.view);
        make.height.mas_equalTo(self.view);
        make.width.mas_equalTo(self.view);
        
    }];
    
    _myTableView.scrollEnabled = NO;
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.backgroundColor = LV;
    [self.myTableView registerClass:[YHYDesignerPTableViewCell class] forCellReuseIdentifier:@"cell"];

    [[UITableViewHeaderFooterView appearance] setTintColor:LV];
    [_myTableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        return 3;
    } else if (section == 1) {
        return 4;
    } else if (section == 2){
        return 2;
    }
    else{
        return 0;
    }


}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
   // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
static NSString *cellstr = @"cell";
    YHYDesignerPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellstr];
//    if (cell == nil) {
//        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellstr];
//    }
   // cell.textLabel.text = [_array objectAtIndex:indexPath.row];
   // cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
  //  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.section == 0) {
        cell.textLabel.text = _array[indexPath.row+ indexPath.section * 1];
       
    }
    if (indexPath.section == 1) {
        cell.textLabel.text = _array[indexPath.row+ 1 + indexPath.section * 2];
        if (indexPath.row == 3) {
             cell.detailTextLabel.text = _mystr;
            
        }
        
    }
    if (indexPath.section == 2) {
        cell.textLabel.text = _array[indexPath.row+ 1+ indexPath.section * 3];
           }
    cell.textLabel.textColor = ZI;
    cell.textLabel.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT * AUTO_WIDTH];
    
    return cell;

    
}
#pragma mark - 选择器
//- (WSCustomPickerView *)customPicker {
//    
//    if (!_customPicker) {
//        self.customPicker = [[WSCustomPickerView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//        self.customPicker.titleStr = @"薪资范围";
//        self.customPicker.delegate = self;
//        [self.view addSubview:self.customPicker];
//    }
//    
//    return _customPicker;
//}
//

//- (WSCustomPickerView *)customPicker{
//    if (!_customPicker) {
//        self.customPicker = [[WSCustomPickerView alloc]initWithFrame:[UIScreen mainScreen].bounds];
//        self.customPicker.titleStr = @"薪资范围";
//        self.customPicker.delegate = self;
//        [self.view addSubview:self.customPicker];
//    }
//    return _customPicker;
//}

//负责传值
- (void)presentReire:(NSMutableArray *)array name:(NSString *)title{
    WSRequirementView *view = [[WSRequirementView alloc]init];
    view.dataArr = array;
    view.delegate = self;
    view.titleLabel.text = title;
    
    [view showView];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   // [self.customPicker showPicker];
    if (indexPath.section == 1 && indexPath.row == 3) {
        NSMutableArray *array = [NSMutableArray arrayWithObjects:@"10",@"30  40",@"40  50", nil];
        [self presentReire:array name:@"薪资范围"];
     }
}
- (void)getSelectData:(NSString *)dataStr{
    _mystr = dataStr;
     [_myTableView reloadData];
}

//- (void)sendAddressInfo:(NSString *)address{
//   
//}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    if (section == 1) {
       
        return 8 * AUTO_HEIGHT;
    }
    
    if (section == 2) {
       return 8 * AUTO_HEIGHT;
    }
    if (section == 3) {
        return 150 * AUTO_HEIGHT;
    }
    
    return 15;
}
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
//    
//    return 1.5 * AUTO_HEIGHT;
//}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    if (section == 3) {
        WSShopInfoNextView *view = [[WSShopInfoNextView alloc] initWithFrame:CGRectMake(0, 40 * AUTO_HEIGHT, SCREEN_WIDTH, 40 * AUTO_HEIGHT)];
        view.delegate = self;
        return view;
    }
    return nil;
}

#pragma mark - 下一步代理
- (void)nextAction {
    
   // [[NSNotificationCenter defaultCenter] postNotificationName:@"ChangeNameNotification" object:self userInfo:@{@"select":@"1"}];
}

-(void)Back:(UIButton *) goback
{
    [self.navigationController popViewControllerAnimated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
